package com.example.declex;

import ohos.aafwk.ability.AbilityPackage;

import com.activeharmony.ActiveHarmony;
import com.activeharmony.Configuration;
import com.activeharmony.util.Log;
import com.chinasoft_ohos.commontools.toast.Toast;
import com.chinasoft_ohos.commontools.util.LogTree;
import com.dspot.declex.annotation.UseLocalDB;
import com.example.declex.model.User_;

import net.sqlcipher.database.SQLiteDatabase;

import org.ohosannotations.annotations.EApplication;

import timber.log.Timber;

@UseLocalDB //使用AbilityOhos 操作数据库。config.json配置MyApplication_时不会走onInitialize方法，系统BUG
@EApplication
public class MyApplication extends AbilityPackage {
    @Override
    public void onInitialize() {
        super.onInitialize();
        Toast.init(this);
        // 尽可能早初始化，一般放在 app 对象的 onInitialize 中
        Timber.plant(new LogTree.HiLog());
        Log.setEnabled(true);
        SQLiteDatabase.loadLibs(this);
        ActiveHarmony.initialize(new Configuration.Builder(this)
            .addModelClass(User_.class)//创建表
            .setPackageName(getBundleName())
            .create());
    }
}
